CREATE TABLE [dbo].[Documents](
	[ID] [uniqueidentifier] NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[FileURL] [nvarchar](255) NOT NULL,
	[InsertTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Documents] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)
);
CREATE TABLE [dbo].[Thumbnail](
	[ID] [uniqueidentifier] NOT NULL,
	[DocumentID] [uniqueidentifier] NOT NULL,
	[PageNumber] [int] NOT NULL,
	[PageThumbnail] [image] NOT NULL,
	[ThumbnailSize] [int] NOT NULL,
 CONSTRAINT [PK_Thumbnail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)
);
ALTER TABLE [dbo].[Documents] ADD  CONSTRAINT [df_documents_id]  DEFAULT (newsequentialid()) FOR [ID];
ALTER TABLE [dbo].[Thumbnail] ADD  CONSTRAINT [df_thumbnail_id]  DEFAULT (newsequentialid()) FOR [ID];
ALTER TABLE [dbo].[Thumbnail]  WITH CHECK ADD  CONSTRAINT [FK_Thumbnail_Documents] FOREIGN KEY([DocumentID]) REFERENCES [dbo].[Documents] ([ID]);
ALTER TABLE [dbo].[Thumbnail] CHECK CONSTRAINT [FK_Thumbnail_Documents];
CREATE NONCLUSTERED INDEX IX_Logs ON dbo.Documents
	(
	FileURL
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY];

